<?php

namespace app\backstage\model;


use app\common\model\Common;
use app\common\model\QuickApp;
use think\model\Pivot;

class QuickAppPush extends Pivot
{
    use Common;
    protected $table = 'quick_app_push';

    /**
     * 投放号
     * @return \think\model\relation\HasOne
     * @Author: whh
     */
    public function channel()
    {
        return $this->hasOne(ManagerUser::class, 'id', 'channel_id')->field("id,account");
    }

    /**
     * App
     * @return \think\model\relation\HasOne
     * @Author: whh
     */
    public function quickApp()
    {
        return $this->hasOne(QuickApp::class, 'id', 'quick_id')->field("id,name");
    }


    /**
     * 获取器
     * @param $value
     * @param $data
     * @return string
     * @Author: whh
     */
    public function getMsgTypeTextAttr($value,$data)
    {
        $msgTypes = [
            'continue' => '继续阅读',
            'sales' => '促销活动',
            'novel' => '小说推荐',
            'sign' => '签到提醒',
        ];
        return $msgTypes[$data['msg_type']];
    }
}